package com.dustedpixels.jasmin.memory.impl;

import com.dustedpixels.jasmin.memory.implbase.Memory16x8ImplBase;

/**
 * 64Kb Random Access Memory.
 */
public final class RAM16x8 extends Memory16x8ImplBase {
    private final byte[] array;
    
    public static RAM16x8 create() {
        return new RAM16x8(new byte[0x10000]);
    }
    
    public static RAM16x8 create(byte[] array) {
        if (array.length != 0x10000) {
            throw new IllegalArgumentException("Array length is not 0x10000.");
        }
        
        return new RAM16x8(new byte[0x10000]);
    }
    
    RAM16x8(byte[] array) {
        this.array = array;
    }
    
    public byte peek(short address) {
        return array[address];
    }

    public void poke(short address, byte value) {
        array[address] = value;
    }
}
